#include <memory>
#include "TcpServer.hpp"
#include "Listener.hpp"

static void Usage(char *arg)
{
    std::cerr << "Usage: " << arg << " port" << std::endl;
}

// ./server port
int main(int argc, char *argv[])
{
    if (argc != 2)
    {
        Usage(argv[0]);
        exit(USAGE_ERR);
    }
    uint16_t port = std::stoi(argv[1]);
    InetAddr addr(port);

    std::shared_ptr<Connection> conn = std::make_shared<Listener>(addr);
    std::unique_ptr<TcpServer> tsvr = std::make_unique<TcpServer>();
    tsvr->AddConnection(conn);

    tsvr->Start();

    return 0;
}